package com.daydayup.learn;

import java.nio.ByteBuffer;

public class CreateBuffer {

    public static void main(String[] args) {
        // 1、创建一个指定长度的缓冲区,以ByteBuffer为例
        ByteBuffer buffer = ByteBuffer.allocate(1024);
        for (int i = 0; i < 5; i++) {
            System.out.println(buffer.get());
        }
        // 2.创建一个有内容的缓冲区
        ByteBuffer wrap = ByteBuffer.wrap("hello".getBytes());
        for (int i = 0; i < 5; i++) {
            System.out.println(wrap.get());
        }
    }
}
